<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE HTML>
<html>
<head>
<title>派送订单</title>
<meta
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
	name="viewport">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="format-detection" content="telephone=yes" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
</head>
<script src="${pageContext.request.contextPath}/js/jquery-1.6.3.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/css/unslider.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
});

function myswitch(num,data){
	if(num==1){
	document.getElementById("orders").style.display="none";
	document.getElementById("personal").style.display="block";
	data.style.background="#FFF";
	document.getElementById("orderlist").style.background="#FF7256";
	}else{
	document.getElementById("orders").style.display="block";
	document.getElementById("personal").style.display="none";
	data.style.background="#FFF";
	document.getElementById("person").style.background="#FF7256";
	}
}
function openAndClose(){
	var node=document.getElementById("updatediv");
	var display=node.style.display;
	if(display=="none"){
		node.style.display="block";
	}else{
		node.style.display="none";
	}
	return false;
}
function updatepwd(){
	if(confirm("确定修改密码?")){
		var opwd=document.getElementById("opwd").value;
	var npwd1=document.getElementById("npwd1").value;
	var npwd2=document.getElementById("npwd2").value;
	var path=document.getElementById("path").value;
	if(npwd1!=npwd2){
	document.getElementById("error").innerHTML="两次输入的不一致!";
	return false;
	}
	$.post(path+"StaffController/updatepwd.action",{"opwd":opwd,"npwd":npwd2},function(result){
			if(result.r==0){
				alert("修改成功!");
				openAndClose();
			}else if(result.r==1){
				document.getElementById("error").innerHTML="登录已过期!"
			}else{
				
				document.getElementById("error").innerHTML="原密码输入错误!"
			}
			
	});
	}
	
}
function update(){
	if(confirm("确定要修改?")){
	var name = document.getElementById("name").value;
	var phonenum = document.getElementById("phonenum").value;
	var path = document.getElementById("path").value;
	if (name == ""||name == null||phonenum == ""||phonenum == null) {
	document.getElementById("error2").innerHTML="不能为空!";
	return false;	
	}
	$.post(path+"StaffController/update.action",{"name":name,"phonenum":phonenum},function(result){
			if(result.r==1){
			alert("修改成功!");
			}else{
			document.getElementById("error2").innerHTML("修改失败!");
			}
			
	});
	}
}
function updateorder(state,id){
		if(confirm("是否提交?")){
		var transport;
		var path = document.getElementById("path").value;
		var data={};
		if(state==4){
		transport=document.getElementById("transport").value;
		if(transport==null||transport==""){
		alert("失败请填写备注原因!");
		return false;
		}
		data={"state":state,"id":id,"transport":transport}
		}else{
		data={"state":state,"id":id,"transport":transport}
		}
		$.post(path+"OrderController/updateToStaff.action",data,function(result){
				if(result.u==0){
				alert("更新失败!请联系管理员.");
				}else{
				alert("成功提交!");
				document.getElementById("content"+id).style.display="none";
				}
		});
		}
}
</script>
<body>
	<div style="height:60px;">
		<div id="orderlist" onclick="return myswitch(0,this)"
			style="width:49%;text-align: center;height:100%;background:#fff;display: inline-block;">
			<span style="font-size: 20px;line-height:60px"> 订单列表 </span>
		</div>
		<div id="person" onclick="return myswitch(1,this)"
			style="width:49%;text-align: center;height:100%;background:#FF7256;display: inline-block;">
			<div>
				<span style="font-size: 20px;line-height:60px;"> 个人中心 </span>
			</div>
		</div>
	</div>
	<div style="display: block" id="orders">
		<c:if test="${orders!=null }">
			<c:forEach items="${orders}" var="order">
				<div style="height:425px;border:1px solid #D3D3D3;margin:10px 0;"
					id="content${order.id }" class="conspan">
					<div>
						<label> 订单编号:${order.id} </label>
					</div>
					<div class="content" style="height:125px">
						<label>商品名称:&nbsp;&nbsp;</label> <br> <span>
							${order.commname} </span> <br> <label>购买数量:</label> <span>${order.num}</span>
						<label>总价:</label> <span>${order.price}元</span> <br> <span>下单时间:</span>
						<fmt:formatDate value="${order.cdate}"
							pattern="yyyy年MM月dd日 HH:mm:ss" />
							<br>
							<span>
							用户备注:${order.remarks}
							</span>
					</div>
					<div class="content">
						<label>联系地址:</label> <br> <span style="color:#191970">${order.img}&nbsp;&nbsp;${order.classname}</span>
						<br> <a href="tel:${order.reason}">
							<div
								style="height:40px;border:1px solid #FF6347;border-radius:6px;
				display:inline-block;color:#fff;background:#FF6347;position:relative;
				width: 63%;text-align: left;">
								<label class="fa fa-phone fa-3x"></label> <label
									style="font-size:28px;color:#fff;display:inline-block;
					position: absolute;top:0px;left:40px">
									<span style="font-size:28px;color:#fff;">${order.reason}</span>
								</label>
							</div>
						</a>
					</div>
					<div class="content">
						<textarea id="transport" rows="4" cols="35" style="resize:none"></textarea>
					</div>
					<div style="border:none" class="content">
						<button class="btns" onclick="return updateorder(4,${order.id})">未完成</button>
						<button class="btns" style="margin-left:5%" onclick="return updateorder(3,${order.id})">已送达</button>
					</div>
				</div>
			</c:forEach>
		</c:if>
	</div>
	<div id="personal"
		style="text-align: center;margin-top: 20px;display: none;position:relative;">
		<label> 账号: </label> <span>${staff.username}</span> <br> <label>
			姓名 </label> <br> <input type="text" value="${staff.name}" id="name" /> <br>
		<label> 联系电话 </label> <br> <input type="text"
			value="${staff.phonenum}" id="phonenum"> <br>
		<button onclick="return update()"
			style="width:200px;height:40px;border-radius:4px;background: #FF6347;
   font-size:18px;color:#fff;border-color:#FF7F24;margin-top:30px;">修改</button>
		<br> <span id="error2" style="color:red"></span> <br>
		<br><br>
		<br> <a style="font-size:18px;" onclick="return openAndClose()">修改密码</a>
		<br><br><br><br>
		 <a href="${pageContext.request.contextPath}/StaffController/outLogin.action">
		退出登录	
		 </a>
		<div
			style="width: 300px;height: 310px;border: 1px solid;position: absolute;
			left:33px;top:20px;background:#fff;text-align: center;display:none"
			id="updatediv">
			<span>原密码</span> <span class="fa fa-close"
				style="position:absolute;left:275px;"
				onclick="return openAndClose()"></span> <br> <input
				type="password" id="opwd"> <br> <span>新密码</span> <br>
			<input type="password" id="npwd1"> <br> <span>确认新密码</span>
			<br> <input type="password" id="npwd2"> <br>
			<button onclick="return updatepwd()"
				style="border-radius:6px;
				height: 50px;width:200px;background:#FF7256;margin-top: 10px">
				确认修改</button>
			<br> <span id="error" style="color:red"></span>
		</div>
	</div>
	<input type="hidden" value="${pageContext.request.contextPath}/"
		id="path">
</body>
<style>
#personal span {
	font-size: 18px;
	margin-top: 10px
}

#personal label {
	font-size: 18px;
	margin-top: 10px
}

#personal input {
	font-size: 18px;
	margin-top: 10px
}

.btns {
	width: 40%;
	height: 50%;
	border-radius: 4px;
	background: #FF6347;
	font-size: 18px;
	color: #fff;
	border-color: #FF7F24;
	margin-top: 4%;
}

.content {
	height: 100px;
	text-align: center;
	width: 100%;
	border-bottom: 1px dashed #CDC5BF;
}

.conspan span {
	font-size: 17px
}
</style>
</html>